#include "qnumbereditor.h"

#include "../property/qabstractproperty.h"

#include <QHBoxLayout>

QNumberEditor::QNumberEditor(QAbstractProperty *property,QWidget *parent):
    QAbstractPropertyEditor(property,parent),
    m_spinbox(new QSpinBox(this))
{
    layout()->addWidget(m_spinbox);
    m_spinbox->setRange(-9999,9999);
    m_spinbox->setValue(property->get_value().toInt());
    connect(m_spinbox,SIGNAL(valueChanged(int)),this,SLOT(value_changed(int)));
    m_spinbox->setContextMenuPolicy(Qt::NoContextMenu);
}

void QNumberEditor::value_changed(int value)
{
    emit property_changed(value);
}

void QNumberEditor::property_value_changed()
{
    m_spinbox->setValue(m_property->get_value().toInt());
}

qRegisterPropertyEditor("Number",QNumberEditor)
